﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;

namespace SYH.Comp
{
    public class UrlFormat
    {
        /// <summary>
        /// 获取新闻页面路径
        /// </summary>
        /// <param name="NewsId">新闻编号</param>
        /// <param name="CreateTime">创建日期</param>
        /// <param name="ColumnName">栏目名称</param>
        /// <returns></returns>
        public static string GetNewsUrl(int NewsId, DateTime CreateTime, string ColumnName)
        {
            if (string.IsNullOrEmpty(ColumnName))
                return "";
            return "/" + ColumnName.ToLower() + "/" + CreateTime.ToString("yyyyMMdd") + NewsId + ".html";
        }

        public static string GetNewsUrl(int NewsId, DateTime CreateTime, string ColumnName,int typeId)
        {
            if (typeId < 32)
            {
                if (string.IsNullOrEmpty(ColumnName))
                    return "";
                return "/" + ColumnName.ToLower() + "/" + CreateTime.ToString("yyyyMMdd") + NewsId + ".html";
            }
            else {

                return string.Format("{0}/XiangPlan/Detail.aspx?Id={2}", MyConst.SYHDomain, ColumnName, NewsId);   
            }
        }


        public static string GetColumnUrl(int ColumnId)
        {
            if (string.IsNullOrEmpty(Enum.GetName(typeof(SYH.Comp.AppEnum.ManageEnum.NewsColumn), ColumnId)))
                return "";
            return "/" + Enum.GetName(typeof(SYH.Comp.AppEnum.ManageEnum.NewsColumn), ColumnId).ToLower() + "/";
        }

        public static string GetNewsHttpUrl(int NewsId, DateTime CreateTime, string ColumnName)
        {
            if (string.IsNullOrEmpty(ColumnName))
                return "";

            return MyConst.NewsDomain + "/" + ColumnName.ToLower() + "/" + CreateTime.ToString("yyyyMMdd") + NewsId + ".html";

        }

        public static string GetColumnHttpUrl(int ColumnId)
        {
            if (string.IsNullOrEmpty(Enum.GetName(typeof(SYH.Comp.AppEnum.ManageEnum.NewsColumn), ColumnId)))
                return "";

            return MyConst.NewsDomain + "/" + Enum.GetName(typeof(SYH.Comp.AppEnum.ManageEnum.NewsColumn), ColumnId).ToLower() + "/";
        }

        /// <summary>
        ///获取公司网站路径
        /// </summary>
        /// <param name="version">会员版本</param>
        /// <param name="admin">会员用户名</param>
        /// <returns></returns>
        public static string GetCompanyUrl(int version, string admin)
        {
            string url = string.Empty;
            //if (version > 0)
            //    url = "http://" + admin.TrimEnd('.') + "." + "qihuiwang.com";
            //else
                url = "http://" + admin.TrimEnd('.') + "." + "shop.qihuiwang.com";
            return url;
            //return GetMemberDomainByVersion(admin, version);
        }

        /// <summary>
        /// 获取产品访问地址
        /// </summary>
        /// <param name="ProductId">产品编号</param>
        /// <param name="FenLei">产品三级分类编号</param>
        /// <returns></returns>
        public static string GetProductUrl(object ProductId, object FenLei)
        {
            return "/product/q3" + Convert.ToString(FenLei) + "/" + ProductId + ".html";
        }
        /// <summary>
        /// 获取产品访问地址
        /// </summary>
        /// <param name="ProductId">产品编号</param>
        /// <param name="UserName">用户商</param>
        /// <returns></returns>
      
        /// <summary>
        /// 获取产品绝对路径地址
        /// </summary>
        /// <param name="ProductId"></param>
        /// <param name="FenLei"></param>
        /// <returns></returns>
        public static string GetSYHProductUrl(object ProductId, object FenLei)
        {
            return MyConst.SYHDomain + "/product/q3" + Convert.ToString(FenLei) + "/" + ProductId + ".html";
        }

        //public static string GetProductUrl(object ProductId, int )
        //{
        //    return "/product/q3" + Convert.ToString(FenLei) + "/" + ProductId + ".html";
        //}

        /// <summary>
        /// 展会地址
        /// </summary>
        /// <param name="ExhId">展会编号</param>
        /// <returns></returns>
        public static string GetExhibitionUrl(int ExhId)
        {
            return "/exhibition/list/" + ExhId + ".html";
        }

        /// <summary>
        /// 展会详细页面地址（高阳）
        /// </summary>
        /// <param name="type">展会类型</param>
        /// <param name="exhId">展会编号</param>
        /// <returns></returns>
        public static string GetExhibitionUrl(object type, object exhId)
        {
            return "/exhibition/" + ((AppEnum.ManageEnum.ExhibitionType)type).ToString().ToLower() + "/" + exhId + ".html";
        }

        /// <summary>
        /// 展会详细页面绝对地址
        /// </summary>
        /// <param name="type">展会类型</param>
        /// <param name="exhId">展会编号</param>
        /// <returns></returns>
        public static string GetSYHExhibitionUrl(object type, object exhId)
        {
            return MyConst.SYHDomain + "/exhibition/" + ((AppEnum.ManageEnum.ExhibitionType)type).ToString().ToLower() + "/" + exhId + ".html";
        }

        /// <summary>
        /// 获取采购路径
        /// </summary>
        /// <param name="OppId"></param>
        /// <param name="industryId"></param>
        /// <param name="typeId">三级分类编号</param>
        /// <returns></returns>
        public static string GetOpportunities(string OppId, string typeId)
        {
            return "/buy/b3" + typeId + "/" + OppId + ".html";
        }

        /// <summary>
        /// 合作
        /// </summary>
        /// <param name="OppId">编号</param>
        /// <param name="industryId">行业</param>
        /// <param name="typeId"></param>
        /// <returns></returns>
        public static string GetCooperateUrl(string OppId, string typeId)
        {
            return "/cooperate/c3" + typeId + "/" + OppId + ".html";

        }
        /// <summary>
        /// 会员网站
        /// </summary>
        /// <param name="Admin"></param>
        /// <returns></returns>
        public static string GetMemberWebDomain(string Admin, bool IsCommon)
        {
            if (IsCommon)
            {
                return string.Format(MyConst.ShopServerFormat, Admin);
            }
            else
            {
                return string.Format(MyConst.webDomain, Admin);
            }

        }
        /// <summary>
        /// 会员网站网址 根据版本
        /// </summary>
        /// <param name="strAdmin"></param>
        /// <param name="iVersion"></param>
        /// <returns></returns>
        public static string GetMemberDomainByVersion(string strAdmin, int iVersion)
        {
            switch ((SYH.Comp.AppEnum.CommonEnum.MemberVersionAll)iVersion)
            {
                case SYH.Comp.AppEnum.CommonEnum.MemberVersionAll.Common:
                    return string.Format(MyConst.shopDomain, strAdmin);
                case SYH.Comp.AppEnum.CommonEnum.MemberVersionAll.Baidu:
                    return string.Format(MyConst.MemberBaiduServerFormat, strAdmin);
                case SYH.Comp.AppEnum.CommonEnum.MemberVersionAll.Advanced:
                case SYH.Comp.AppEnum.CommonEnum.MemberVersionAll.Diamond:
                case SYH.Comp.AppEnum.CommonEnum.MemberVersionAll.Gold:
                    return string.Format(MyConst.webDomain, strAdmin);
            }
            return "";

        }
        /// <summary>
        /// 会员招聘列表页
        /// </summary>
        /// <param name="Admin"></param>
        /// <returns></returns>
        public static string GetMemberJobUrl(string Admin)
        {
            return string.Format(MyConst.MemberJobUrl, Admin);
        }


        #region 商都网

        /// <summary>
        /// 商都合作项目---传入用户编号得到公司首页地址
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public static string GetShangDuIndexUrl(string id)
        {
            return string.Format("http://shangdu.hezuo.qihuiwang.com/index.aspx?pid={0}", id);
        }
        /// <summary>
        /// 商都合作项目---传入产品编号得到产品详细
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public static string GetShangDuProductUrl(string id)
        {
            return string.Format("http://shangdu.hezuo.qihuiwang.com/productdetail.aspx?id={0}", id);
        }
        /// <summary>
        /// 商都合作项目---传入求购信息编号得到求购详细信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public static string GetShangDuPurchaseUrl(string id)
        {
            return string.Format("http://shangdu.hezuo.qihuiwang.com/purchasedetail.aspx?id={0}", id);
        }

        #endregion





        /// <summary>
        ///获取公司网站路径
        /// </summary>
        /// <param name="version">会员版本</param>
        /// <param name="admin">会员用户名</param>
        /// <returns></returns>
        public static string GetCompanyUrl(int version, string admin, int id)
        {
            if (id > 0)
            {
                return GetMemberDomainByVersion(admin, version);
            }
            else
            {
                //商都网公司地址
                return GetShangDuIndexUrl(id.ToString());

            }
        }


        /// <summary>
        /// 获取产品访问地址
        /// </summary>
        /// <param name="ProductId">产品编号</param>
        /// <param name="FenLei">产品三级分类编号</param>
        /// <returns></returns>
        public static string GetProductUrl(object ProductId, object FenLei, int memberId)
        {
            if (memberId > 0)
            {
                return "/product/q3" + Convert.ToString(FenLei) + "/" + ProductId + ".html";
            }
            else
            {
                //商都网产品地址

                return GetShangDuProductUrl(memberId.ToString());
            }
        }
        /// <summary>
        /// 合作
        /// </summary>
        /// <param name="OppId">编号</param>
        /// <param name="industryId">行业</param>
        /// <param name="typeId"></param>
        /// <returns></returns>
        public static string GetCooperateUrl(string OppId, string typeId, int memberid)
        {
            if (memberid > 0)
            {
                return "/cooperate/c3" + typeId + "/" + OppId + ".html";
            }
            else
            {
                //商都网采购地址
                return GetShangDuPurchaseUrl(memberid.ToString());

            }

        }
    }
}
